package cal

import (
	"idle/internal/game/attr"
	"idle/internal/game/hero"
)

type DefAttrCal struct {
}

func (d *DefAttrCal) Cal(h *hero.Hero) {
	baseDef := h.GetAttr(attr.Dex) / 4
	h.SetAttr(attr.BaseDef, baseDef)

	extDef := h.GetAttr(attr.ExtDef)
	extDefRatio := h.GetAttr(attr.EnhanceDefence)
	totalDef := (baseDef + extDef) * (100 + extDefRatio) / 100

	h.SetAttr(attr.Def, totalDef)
}

func (d *DefAttrCal) AssociatedAttr() []attr.Attribute {
	return []attr.Attribute{attr.Dex, attr.ExtDef, attr.EnhanceDefence}
}
